package com.example.administrator.testc.PagerAdapter;/**
 * Created by Administrator on 2016/5/1 0001.
 */

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.example.administrator.testc.R;

import java.util.ArrayList;
import java.util.List;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * DrawerLayout侧栏 + ViewPager Demo
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class TestMain extends AppCompatActivity {

    private DrawerLayout drawerLayout;
    private LinearLayout left_line, left_line2;
//    private List<View> mDates = new ArrayList<>();
    private List<Fragment> mDates = new ArrayList<>();
    private ViewPager viewpager;
//    private Adapter adapter;
    private ActionBarDrawerToggle mDrawerToggle;
    private FragmentAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pagerfragment);
        init();
//        adapter = new Adapter(mDates, this);
        adapter = new FragmentAdapter(getSupportFragmentManager(), mDates);
        viewpager.setAdapter(adapter);
    }

    private void findView(){
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        viewpager = (ViewPager) findViewById(R.id.viewpager);
        left_line = (LinearLayout) findViewById(R.id.left_line);
        left_line2 = (LinearLayout) findViewById(R.id.left_line2);
    }


    private void init() {
        findView();
//        Button view = new Button(this);
//        view.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                drawerLayout.openDrawer(left_line);
//                drawerLayout.openDrawer(left_line2);
////                drawerLayout.openDrawer(Gravity.LEFT);
////                drawerLayout.openDrawer(Gravity.RIGHT);
//            }
//        });
//        mDates.add(view);
//        mDates.add(new CView(this, Color.GREEN));
//        mDates.add(new CView(this, Color.BLUE));
//        mDates.add(new CView(this, Color.YELLOW));
        mDates.add(new TestFragment(Color.RED));
        mDates.add(new TestFragment(Color.GREEN));
        mDates.add(new TestFragment(Color.BLUE));
        mDates.add(new TestFragment(Color.YELLOW));
    }

    private class CView extends View {

        public CView(Context context, int color) {
            super(context);
            this.setBackgroundColor(color);
        }

    }
}